<?php
class Group
{
	public $exitCode = 2;
	public $exitText = "The exit code was not set";
	public $infoReturned = false;
	
	public function getInfo($groupName)
	{
		$this->groupName = crowFather($groupName,6);
		if(crowFather("select count(*) from groups where groupName = " . $this->groupName . ";",5) == 1)
		{		
			foreach(crowFather("select groupOwner,groupDescription,activeGroup from groups where groupName = " . $this->groupName . ";",4) as $object)
			{
				$this->groupOwner = $object[0];
				$this->groupDescription = $object[1];
				$this->activeGroup = $object[2];
				$this->infoReturned = true;
			}
			
			foreach(crowFather("select userName from participant where groupName = " . $this->groupName . ";",4) as $index=>$user)
			{
				$this->addedUsers[$index] = $user[0];
			}
			
			$this->giveExitStatus(0,"The information for the group was given");
		}
		else
		{
			$this->giveExitStatus(1,"The groupName provided dosen't exist");
		}
		
		
	}
	
	public function deleteGroup($group = "")
	{
		$groupSet = false;
		
		if($group != "")
		{
			$groupSet = true;
		}
		else
		{
			if($this->groupName != "")
			{
				$groupSet = true;
			}
			else
			{
				$this->giveExitStatus(1,"No group was given");
			}
		}
		if($groupSet == true)
		{
			
			crowFather("update groups set activeGroup = 'N' where groupName  " . crowFather($group,6) . ";",3);
		}
	}
	
	private function giveExitStatus($exitCode,$exitText)
	{
		$this->exitCode = $exitCode;
		$this->exitText = $exitText;
	}
}
?>